import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-06-09
 * Time: 17:41
 */
public class TestDemo {
    public static void main(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("cww",5);
        map.put("wxw",7);
        map.put("awe",4);
        System.out.println(map.containsKey("wxww"));
    }
    public static void main5(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("cww",5);
        map.put("wxw",7);
        map.put("awe",4);

        Set<Map.Entry<String,Integer>> entry = map.entrySet();
        for (Map.Entry<String,Integer> set:entry) {
            System.out.println(set.getKey()+" " + set.getValue()+" ");
        }

    }
    public static void main4(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("www",5);
        map.put("wew",7);
        map.put("wwe",4);

        //返回value值到集合当中
        Collection<Integer> list = map.values();
        System.out.println(list);
    }
    public static void main3(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("www",5);
        map.put("wew",7);
        map.put("wwe",4);

        //获取Key值存储到Set集合当中
        Set<String> set = map.keySet();
        System.out.println(set);
    }
    public static void main2(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("www",5);
        map.put("wew",7);
        map.put("wwe",4);

        //获取key值对应的value值，如果没有Key值就返回默认值
        System.out.println(map.getOrDefault("wwww",199));
        System.out.println(map.getOrDefault("www",199));
    }
    public static void main1(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        //put添加Key和value值   Key不可修改，Value可以修改
        map.put("www",5);
        map.put("wwww",7);
        map.put("wwe",4);


        System.out.println(map);
        //get获取Key对应的value值
        System.out.println(map.get("wew"));
        System.out.println(map.get("www"));

    }
}
